<template>
  <div>
    <van-nav-bar :title="comment.reply_count ?comment.reply_count+'条回复' :'暂无回复'">
      <template #left>
        <van-icon name="cross" @click="$emit('closeReply')"/>
      </template>
    </van-nav-bar>
    <div class="scroll-center">
      <CommentItem :row="comment"/>
      <van-cell title="全部回复"/>
      <CommentList type="c" :source="comment.com_id" :list="list"/>
    </div>
    <!-- 底部评论按钮 -->
    <div class="post-warp">
      <van-button @click="isShowReplyPost=true" round>评论</van-button>
    </div>
    <van-popup v-model="isShowReplyPost" position="bottom">
      <CommentPost
        :target="comment.com_id"
        :artId="$route.params.articleId"
        @postSuccess="onPostSuccess"
      />
    </van-popup>
  </div>
</template>

<script>
import CommentItem from '@/components/commentItem.vue'
import CommentList from '@/components/commentList.vue'
import CommentPost from './commentPost.vue'
export default {
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      list: [],
      isShowReplyPost: false
    }
  },

  created () {

  },

  methods: {
    onPostSuccess (obj) {
      this.list.unshift(obj)
      this.isShowReplyPost = false
    }
  },
  components: {
    CommentItem,
    CommentList,
    CommentPost
  }
}
</script>

<style scoped lang="less">
.post-warp {
  width: 100%;
  height: 100px;
  position: fixed;
  bottom: 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #8df;
  .van-button {
    width: 640px;
    height: 80px;
  }
}
.scroll-center{
  position: absolute;
  top: 92px;
  bottom: 102px;
  width: 100%;
  overflow-y: scroll;
}
</style>
